Description:
IDFC detects situations where precision may be lost as a result of integer division. It can happen when an integer value is divided by another integer and the result is either assigned to a floating-point variable, or the result is used in a floating-point expression. It may not be clear that the conversion to a floating-point type is done after the division.
Incorrect:
void calcBounds(int size) {
double border = size / 20;
// if size was 18, d now unexpectably equals 0.0
...
}
Correct:
void calcBounds(int size) {
double border = size / 20.0;
...
}